//
//  CustomServiceMessageViewController.m
//  HAODE
//
//  Created by LiYinDi on 16/1/8.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "CustomServiceMessageViewController.h"
#import "RDVTabBarController.h"

#import "HttpRequest.h"
#import "TheLoginViewController.h"
#import "ConversationViewController.h"
@interface CustomServiceMessageViewController ()<RCIMUserInfoDataSource>
{
    
}

@end

@implementation CustomServiceMessageViewController
-(id)init
{
    self=[super init];
    if (self) {
//        [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),
//                                            @(ConversationType_DISCUSSION),
//                                            
//                                            @(ConversationType_GROUP)
//                                            
//                                             ]];
        //设置需要将哪些类型的会话在会话列表中聚合显示
//        [self setDisplayConversationTypes:@[ @(ConversationType_PRIVATE),
//                                               @(ConversationType_DISCUSSION),
//                                               
//                                               @(ConversationType_GROUP)
//                                               ]];

        
    }
    return self;
}






- (void)viewDidLoad {
    [super viewDidLoad];
//    NSLog(@"eeerrrr");
    [self setNavigation];
//    [RCIM sharedRCIM].receiveMessageDelegate = nil;
    [self setDisplayConversationTypes:@[ @(ConversationType_PRIVATE),
                                         @(ConversationType_DISCUSSION),
                                         
                                         @(ConversationType_GROUP)
                                         ]];



    
    
}
- (void)onRCIMReceiveMessage:(RCMessage *)message left:(int)left{


}

- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
         conversationModel:(RCConversationModel *)model
               atIndexPath:(NSIndexPath *)indexPath {
    ConversationViewController *conversationVC = [[ConversationViewController alloc]init];
//   NSLog(@"ddd===%d",model.conversationType);
//    conversationVC.conversationType = ConversationType_PRIVATE;
    conversationVC.conversationType = model.conversationType;
    conversationVC.targetId = [NSString stringWithFormat:@"%@",model.targetId];
    NSLog(@"model.targetId===%@",model.targetId);
    conversationVC.title =model.conversationTitle;
//    conversationVC.userName =model.conversationTitle;
    [self.navigationController pushViewController:conversationVC animated:YES];
}

-(void)setNavigation
{
   [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    UILabel* titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,40, 23)];
    titleLabel.text=@"客服消息";
    titleLabel.font=[UIFont systemFontOfSize: 17];
    self.navigationItem.titleView=titleLabel;
    
    
//    UIButton* rightButton= [[UIButton alloc] initWithFrame:backframe];
//    [rightButton setTitle:@"单聊" forState:UIControlStateNormal];
//    [rightButton setTitleColor:[UIColor colorWithRed:90.0f/255.0f green:130.0f/255.0f blue:26.0f/255.0f alpha:1.0] forState:UIControlStateNormal];
//    rightButton.titleLabel.textAlignment=NSTextAlignmentCenter;
//    [rightButton addTarget:self action:@selector(rightBtnItemAction) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem* rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
//    self.navigationItem.rightBarButtonItem = rightBarButtonItem;

}
//-(void)rightBtnItemAction
//{
//    ConversationViewController *conversationVC = [[ConversationViewController alloc]init];
//    //   NSLog(@"ddd===%d",model.conversationType);
//    conversationVC.conversationType = ConversationType_PRIVATE;
//    conversationVC.targetId = @"Conversation";
//    
//    conversationVC.title =@"Conversation";
//    
//    [self.navigationController pushViewController:conversationVC animated:YES];
//}
-(void)BackAction:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
